﻿using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Father
{ }

public class Son : Father
{ }


public class Reflection : MonoBehaviour
{
    private void Start()
    {
        //如何通过反射知道泛型类型
        List<float> list = new List<float>();
        Type listType = list.GetType();
        //获取泛型类型
        Type[] genericType = listType.GetGenericArguments();
        foreach (Type t in genericType)
        {
            //System.Single
            print(t);
        }
        
        Dictionary<int,string> dic = new Dictionary<int,string>();
        Type dicType = dic.GetType();
        Type[] dicgenericType = dicType.GetGenericArguments();
        foreach (Type t in dicgenericType)
        {
            //System.Int32 和 System.string
            print(t);
        }
    }
}
